package hongcaosp.app.android.contact.friends;

import java.util.ArrayList;
import java.util.List;

import hongcaosp.app.android.common.IListView;
import hongcaosp.app.android.login.UserToken;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.bean.DirectoryWrapper;
import hongcaosp.app.android.modle.bean.IUserDetail;
import hongcaosp.app.android.modle.impl.UserModleImpl;
import hongcaosp.app.android.modle.mi.UserModle;
import xlj.lib.android.base.component.BasePresenter;

public class LocalFindFriendPresenter extends BasePresenter {

    private IListView<IUserDetail> listView;
    private UserModle userModle;

    public LocalFindFriendPresenter(IListView<IUserDetail> listView) {
        this.listView = listView;
        userModle = new UserModleImpl();
    }

    public void fresh(List<String> mobiles) {
        userModle.directoriesFriends(UserToken.getDefault().getToken(), mobiles, new DataCallBack<DirectoryWrapper>() {
            @Override
            public void onGetData(DirectoryWrapper data) {
                super.onGetData(data);
                List<IUserDetail> userList = new ArrayList<>();
                if (data.getDirectoriesFriends() != null) {
                    userList.addAll(data.getDirectoriesFriends());
                }
                listView.freshList(userList,false);
            }

            @Override
            public void onFail(int code, String errorMessage) {
                super.onFail(code, errorMessage);
            }
        });
    }
}
